package de.ttf.ts.control.impl;

import de.ttf.ts.control.PlayerController;
import de.ttf.ts.control.impl.dao.ClubDao;
import de.ttf.ts.control.impl.dao.PlayerDao;
import de.ttf.ts.model.Club;
import de.ttf.ts.model.EntityInfo;
import de.ttf.ts.model.Player;

public class PlayerControllerImpl extends AbstractController implements PlayerController {

    private PlayerDao playerDao;
    private ClubDao clubDao;

    @Override
    public void savePlayer(EntityInfo<Player> info, EntityInfo<Club> clubInfo, String firstName, String lastName) {
    	
    	Club club = find(clubDao, clubInfo);
    	
    	Player player = findOrCreate(Player.class, playerDao, info);
    	player.setFirstName(firstName);
    	player.setLastName(lastName);
    	
    	player.setClub(club);
    }
    
    public void setClubDao(ClubDao clubDao) {
		this.clubDao = clubDao;
	}

    public void setPlayerDao(PlayerDao playerDao) {
        this.playerDao = playerDao;
    }

}
